<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="shortcut icon" href="../favicon.png" />
    <link rel="stylesheet" href="../js/layui/css/layui.css" />
    <link rel="stylesheet" href="../style/index.css" />
    <link rel="stylesheet" href="../style/style.css" />
    <title>single css layout</title>
  </head>
  <body>
    <div class="root">
      <div class="m-img layui-anim layui-anim-rotate layui-anim-loop">
        <img src="../images/kaixin.png" alt="..." width="75" />
      </div>
      <div class="fix-btn-change">切换多页面显示</div>
      <div class="navbar">
        <ul>
          <li class="active">布局 1</li>
          <li>布局 2</li>
          <li>布局 3</li>
          <li>布局 4</li>
          <li>布局 5</li>
        </ul>
      </div>
      <div class="content">
        <ul>
          <li class="active layui-anim layui-anim-upbit">
            <div class="layout1">
              <div class="container">内容</div>
            </div>
          </li>
          <li class="layui-anim layui-anim-upbit">
            <div class="layout2">
              <div class="header">头部</div>
              <div class="container">内容</div>
              <div class="footer">底部</div>
            </div>
          </li>
          <li class="layui-anim layui-anim-upbit">
            <div class="layout3">
              <div class="sidebar">侧边</div>
              <div class="container">内容</div>
            </div>
          </li>
          <li class="layui-anim layui-anim-upbit">
            <div class="layout4">
              <div class="header">头部</div>
              <div class="container">
                <div class="sidebar">侧边</div>
                <div class="content">内容</div>
              </div>
              <div class="footer">底部</div>
            </div>
          </li>
          <li class="layui-anim layui-anim-upbit">
            <div class="layout5">
              <div class="header">头部</div>
              <div class="header-bottom">夹层</div>
              <div class="container">
                <div class="left">左侧</div>
                <div class="center">内容</div>
                <div class="right">右侧</div>
              </div>
              <div class="footer">底部</div>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="loading-mark">
      <i
        class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"
        style="font-size: 35px"
      >
      </i>
      <div style="margin-top: 10px">加载中...</div>
    </div>
    <script src="../js/layui/layui.js"></script>
    <script>
      // 以下功能实现的是菜单切换布局显示的功能
      // 选择出菜单项和菜单内容项
      let navbarItems = document.querySelectorAll(".navbar li");
      let contentItems = document.querySelectorAll(".content li");

      // 实现切换
      for (let i = 0; i < navbarItems.length; i++) {
        navbarItems[i].addEventListener("click", () => {
          let index = i;
          for (let j = 0; j < navbarItems.length; j++) {
            navbarItems[j].classList.remove("active");
            contentItems[j].classList.remove("active");
          }
          navbarItems[index].classList.add("active");
          contentItems[index].classList.add("active");
        });
      }

      // 切换显示方式
      let fixBtnChange = document.querySelector(".fix-btn-change");
      fixBtnChange.onclick = function () {
        location.href = "../index.html";
        // history.back();
      };

      // 加载遮罩层
      setTimeout(() => {
        let root = document.querySelector(".root");
        root.style.display = "block";
        let loadingMark = document.querySelector(".loading-mark");
        loadingMark.style.display = "none";
      }, 500);
    </script>
  </body>
</html>
